# 使用英伟达官方CUDA镜像
FROM nvidia/cuda:12.2.0-base-ubuntu22.04
# 工作目录设置为/app
WORKDIR /app
# 设置镜像时区为中国时区
COPY ./resource/Shanghai /etc/localtime

# 安装Miniconda
COPY ./resource/Miniconda3.sh .
RUN chmod +x Miniconda3.sh
RUN ./Miniconda3.sh -b -p /root/miniconda3/
ENV PATH="/root/miniconda3/condabin:${PATH}"
RUN rm -f ./Miniconda3.sh

# mini配置清华源
COPY ./resource/.condarc /root/.condarc
RUN conda clean -i

# 安装依赖
COPY ./resource/environment.yaml .
RUN conda env create -f environment.yaml

# 复制代码所需文件到容器中
COPY ./code/train.py .
COPY ./code/data/MNIST/raw/*.gz ./data/MNIST/raw/
CMD ["/root/miniconda3/envs/torch-gpu/bin/python", "-u", "train.py"]